# Copyright 2023 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@teeapps//bazel:teeapps.bzl", "teeapps_cc_library", "teeapps_cc_test")

package(default_visibility = ["//visibility:public"])

teeapps_cc_library(
    name = "json2pb",
    hdrs = ["json2pb.h"],
    deps = [
        "@com_github_grpc_grpc//:grpc++",
        "@yacl//yacl/base:exception",
    ],
)

teeapps_cc_library(
    name = "ra_util",
    srcs = ["ra_util.cc"],
    hdrs = ["ra_util.h"],
    deps = [
        "//teeapps/proto:cc_sf_apis_proto",
        "@com_github_rapidjson//:rapidjson",
        "@com_google_absl//absl/strings",
        "@cppcodec",
        "@jinzhao_attest//:generation",
        "@jinzhao_attest//:verification",
        "@yacl//yacl/crypto/base/hash:hash_utils",
    ],
)

teeapps_cc_library(
    name = "crypto_util",
    srcs = ["crypto_util.cc"],
    hdrs = ["crypto_util.h"],
    deps = [
        ":io_util",
        "//teeapps/proto:cc_sf_apis_proto",
        "//teeapps/utils:json2pb",
        "@cppcodec",
        "@yacl//yacl/crypto/base:digital_envelope",
        "@yacl//yacl/crypto/base:hmac_sha256",
        "@yacl//yacl/crypto/base:rsa_signing",
        "@yacl//yacl/crypto/utils:rand",
        "@yacl//yacl/io/stream:file_io",
    ],
)

teeapps_cc_test(
    name = "crypto_util_test",
    srcs = ["crypto_util_test.cc"],
    deps = [
        ":crypto_util",
    ],
)

teeapps_cc_library(
    name = "io_util",
    srcs = ["io_util.cc"],
    hdrs = ["io_util.h"],
    deps = [
        "@yacl//yacl/base:byte_container_view",
        "@yacl//yacl/io/stream:file_io",
    ],
)

teeapps_cc_library(
    name = "log",
    srcs = ["log.cc"],
    hdrs = ["log.h"],
    deps = [
        "@yacl//yacl/base:exception",
    ],
)

teeapps_cc_library(
    name = "tool",
    srcs = ["tool.cc"],
    hdrs = ["tool.h"],
    deps = [
        "@com_github_rapidjson//:rapidjson",
        "@yacl//yacl/base:exception",
    ],
)

teeapps_cc_library(
    name = "task_config_util",
    srcs = ["task_config_util.cc"],
    hdrs = ["task_config_util.h"],
    deps = [
        "//teeapps/component:eval_param_reader",
        "//teeapps/framework:constants",
        "//teeapps/proto:cc_sf_spec_proto",
        "//teeapps/proto:cc_task_proto",
        "//teeapps/utils:data_uri_util",
        "//teeapps/utils:io_util",
        "//teeapps/utils:json2pb",
        "@yacl//yacl/base:exception",
    ],
)

teeapps_cc_library(
    name = "output_dist_data_util",
    srcs = ["output_dist_data_util.cc"],
    hdrs = ["output_dist_data_util.h"],
    deps = [
        "//teeapps/component:util",
        "//teeapps/framework:constants",
        "//teeapps/proto:cc_kuscia_proto",
        "//teeapps/proto:cc_sf_spec_proto",
        "//teeapps/utils:data_uri_util",
        "//teeapps/utils:io_util",
        "//teeapps/utils:json2pb",
        "//teeapps/utils:task_config_util",
        "@yacl//yacl/base:exception",
    ],
)

teeapps_cc_library(
    name = "data_uri_util",
    srcs = ["data_uri_util.cc"],
    hdrs = ["data_uri_util.h"],
    deps = [
        "@com_github_httplib//:httplib",
        "@yacl//yacl/base:exception",
    ],
)
